home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 3
/
Cream of the Crop 3.iso
/
comm
/
wnos5src.zip
/
ARPDUMP.C
< prev
next >
Wrap
Text File
|
1993-07-27
|
2KB
|
68 lines
#include "global.h"
#include "mbuf.h"
#include "arp.h"
#include "netuser.h"
#include "trace.h"
void
arp_dump(FILE *fp,struct mbuf **bpp)
{
struct arp arp;
struct arp_type *at;
char is_ip = 0, op = 0, tmp[30];
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
if(ntoharp(&arp,bpp) == -1){
trprintf(fp,"ARP: bad packet\n");
return;
}
at = (arp.hardware < NHWTYPES) ? &Arp_type[arp.hardware] : NULLATYPE;
/* Print hardware type in Ascii if known, numerically if not */
trprintf(fp,"ARP: len %d hwtype %s",
len_p(*bpp),Arptypes[arp.hardware]);
/* Print hardware length only if unknown type, or if it doesn't match
* the length in the known types table
*/
if(at == NULLATYPE || arp.hwalen != at->hwalen)
trprintf(fp," hwlen %u",arp.hwalen);
/* Check for most common case -- upper level protocol is IP */
if(at != NULLATYPE && arp.protocol == at->iptype){
trprintf(fp," prot IP op ");
is_ip = 1;
} else {
trprintf(fp," prot 0x%x prlen %u op ",arp.protocol,arp.pralen);
}
if(arp.opcode == RARP_REQUEST || arp.opcode == RARP_REPLY)
trprintf(fp,"REVERSE ");
switch(arp.opcode){
case ARP_REQUEST:
trprintf(fp,"REQUEST\n");
break;
case ARP_REPLY:
trprintf(fp,"REPLY\n");
op = 1;
break;
default:
trprintf(fp,"%u\n",arp.opcode);
break;
}
trprintf(fp," HW: sender %s",at->format(tmp,arp.shwaddr));
if(op) {
trprintf(fp," target %s",at->format(tmp,arp.thwaddr));
}
trprintf(fp,"\n");
if(is_ip) {
trprintf(fp," IP: sender %s",inet_ntoa(arp.sprotaddr));
trprintf(fp," target %s\n",inet_ntoa(arp.tprotaddr));
}
}